﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Autofac;
using Autofac.Core;
using BusinessLogicLayer;
using DataAccessLayer;
using Entity;
using IBusinessLogicLayer;
using IDataAccessLayer;

namespace ConsoleApp
{
    class Program
    {
        private static IContainer Container { get; set; }
        static void Main(string[] args)
        {
            //var builder = new ContainerBuilder();
            //builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof (CityDal)))
            //    .Where(u => u.Name.EndsWith("Dal"))
            //    .AsImplementedInterfaces();
            //builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(CityBll)))
            //   .Where(u => u.Name.EndsWith("Bll"))
            //   .AsImplementedInterfaces();
            //Container = builder.Build();
            ////Add();
            ////TestOne();
            //Delete();
            //TestOne();
        }

        //public static void TestOne()
        //{
        //    using (var scope = Container.BeginLifetimeScope())
        //    {
        //        var bll = scope.Resolve<ICityBll>();
        //        foreach (var city in bll.GetCities())
        //        {
        //            Console.WriteLine($"{city.Id}   {city.Name}   {city.ZipCode}");
        //        }
        //    }
        //}

        //public static void Add()
        //{
        //    using (var scope = Container.BeginLifetimeScope())
        //    {
        //        var bll = scope.Resolve<ICityBll>();
        //        bll.Insert(new City() {Name = "阜新", ZipCode = "100025"});
        //    }
        //}
        //public static void Delete()
        //{
        //    using (var scope = Container.BeginLifetimeScope())
        //    {
        //        var bll = scope.Resolve<ICityBll>();
        //        bll.Delete(c => c.Id == 4);
        //    }
        //}
    }
}
